//给两边的固定侧栏加功能
var totop = document.getElementById("special_div");
totop.onclick = function () {
    //回到顶部
    document.documentElement.scrollTop = 0;
    document.body.scrollTop = 0;
}
var login = document.getElementById("login");
var shuxian = document.getElementById("shuxian");
var register = document.getElementById("register");
var delbgcolor = function(obj){
    //该函数用于修正一些不太好的样式
    obj.addEventListener("mouseover",function(){
        this.style.backgroundColor="#333333";
    })
}
var left = document.getElementsByClassName("iot_fixed_left");
var right = document.getElementsByClassName("iot_fixed_right");
var airtored = document.getElementById("airdiv");
var air_a = document.getElementById("air_a");
window.onscroll=function(){
    //滚动到适合位置时显示侧栏
    var scrollvalue=document.body.scrollTop||document.documentElement.scrollTop;
    if (scrollvalue>200&&scrollvalue<1200){
        for(let i=0;i<left.length;i++){
            left[i].style.display="block";
        }
        if(scrollvalue>500&&scrollvalue<1000){
            airtored.style.backgroundColor="red";
            air_a.style.color="white";
        }
        else{
            airtored.style.backgroundColor="white";
            air_a.style.color="black";
        }
    }
    else{
        for(let i=0;i<left.length;i++){
            left[i].style.display="none";
        }
    }
    if (scrollvalue>300) {
        for(let i=0;i<right.length;i++){
            right[i].style.display="block";
        }
    }
    else{
        for(let i=0;i<right.length;i++){
            right[i].style.display="none";
        }
    }
}
delbgcolor(login);
delbgcolor(register);
delbgcolor(shuxian);